﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <script src="../../js/load.js"></script>
</head>

<body>
    <div id="container">
        <div id="formcontainer">
            <form class="layui-form layui-form-pane" id="editform" lay-filter="editform">
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label">备份选择</label>
                            <div class="layui-input-block">
                                <select name="BackUpFileName" id="BackUpFileName" lay-filter="BackUpFileName" class="required"></select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label">注意事项</label>
                            <spam class="layui-input" style="color:red;font-size: 18px;font-weight: bold;line-height: 38px;" id="tip"></spam>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div id="opcontainer">
            <button class="layui-btn" onclick="HandleSave()">确认</button>
            <button class="layui-btn layui-btn-primary" onclick="HandleClose()">关闭</button>
        </div>
    </div>
</body>
</html>
<script>
    $(function () {
        BindBackUp();
    })

    function HandleSave() {
        var param = {
            projectID: GetUrlParam("projectID"),
            backUpFileName: $('#BackUpFileName option:selected').val()
        }
        HttpPost(JSON.stringify(param), 'api/depoly/recoverBackUp', function (result) {
            if (result.code == 0) {
                OpenSuccess('还原成功', function (params) {
                    CloseDialog();
                })
            } else {
                OpenFail(result.msg);
            }
        })

    }


    function HandleClose() {
        CloseDialog();
    }

    function BindBackUp() {
        $("#BackUpFileName").html("");
        var param = {
            projectID: GetUrlParam("projectID")
        }
        HttpPost(JSON.stringify(param), 'api/depoly/getBackUpList', function (result) {
            if (result.code == 0) {
                var backuplist = result.data.obj;
                var backupcount = result.data.backupcount;
                $("#tip").text("自动备份只保留最新"+backupcount+"条上传记录");
                for (var i = 0; i < backuplist.length; i++) {
                    $("#BackUpFileName").append("<option  value='" + backuplist[i] + "' >" + backuplist[i] + "</option>");
                }
                layui.form.render();
            }
        })
    }
</script>